• 2022-08-27
  • unique

Minecraft Server

install dependecies

apt -y install openjdk-11-jdk jq vim curl tmux
# or 
dnf install java-17-openjdk-headless vim curl jq tar

Use mcrcon as rcon client

curl -L $(curl -s https://api.github.com/repos/Tiiffi/mcrcon/releases/latest | jq --raw-output '.assets[1] | .browser_download_url') -o mcrcon.tar.gz
tar --wildcards --strip-components 1 -xzvf mcrcon.tar.gz */mcrcon

you can use the following systemd service file

[Unit]
Description=Minecraft Server
Documentation=

Wants=network.target
After=network.target

[Service]
User=minecraft
Group=minecraft
Nice=5
EnvironmentFile=-/opt/minecraft/service.conf
KillMode=none
SuccessExitStatus=0 1

ProtectHome=true
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
PrivateTmp=true
InaccessibleDirectories=/root /sys /srv /media -/lost+found /var
ReadWriteDirectories=/opt/minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/usr/bin/java -Xmx1024M -Xms1024M -jar server.jar --noconsole
ExecStop=/opt/mc-mgmt/dl/mcrcon -H localhost -P $port -p $password stop

[Install]
WantedBy=multi-user.target
adduser -m -r -U -d /opt/minecraft/ minecraft

and configure the following server.properties file

# Allowed values: "survival", "creative", "spectator" or "adventure"
gamemode=survival

motd=a Server
white-list=false
hardcore=true
# Allowed values: "peaceful", "easy", "normal" or "hard"
difficulty=normal
view-distance=10
enable-rcon=true
rcon.password=${THE PASSWORD}
rcon.port=25575
enable-command-block=false
pvp=true
network-compression-threshold=256
max-tick-time=60000
max-players=20
online-mode=true
allow-nether=true
force-gamemode=false
spawn-npcs=true
function-permission-level=2
level-type=default
text-filtering-config=
max-world-size=29999984
enable-jmx-monitoring=false
level-seed=
enable-query=false
generator-settings=
level-name=world
query.port=25565
generate-structures=true
require-resource-pack=false
use-native-transport=true
enable-status=true
allow-flight=false
broadcast-rcon-to-ops=true
server-ip=
server-port=25565
sync-chunk-writes=true
op-permission-level=4
prevent-proxy-connections=false
resource-pack=
entity-broadcast-range-percentage=100
player-idle-timeout=0
rate-limit=0
broadcast-console-to-ops=true
spawn-animals=true
snooper-enabled=true
spawn-monsters=true
enforce-whitelist=false
resource-pack-sha1=
spawn-protection=0

plugins

BungeeCord

Minecraft

build minecraft

apt -y install wget git javac

# delete old if exists and download new build tool
rm BuildTools.jar


# build the latest spigot release
java -jar BuildTools.jar --rev latest

convert UUID to username

#!/usr/bin/env bash

#
# Get Current Names of all Players Listed in "{minecraft folder}/world/playerdata/*.dat"
#
# needs to be executed in "{minecraft folder}/world/playerdata"
#

for UUID in *; do
        UUID=$(echo $UUID | cut -c 1-36)
        UUID=$(echo $UUID | sed 's/\-//g')
        curl -s https://api.mojang.com/user/profiles/$UUID/names | jq '.[-1].name'
done

install update bungeecord

cd /srv/bungee/
mv BungeeCord.jar BungeeCord.jar.bak
wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar -O BungeeCord.jar
systemctl restart bungee
systemctl status bungee

datapacks